<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>cornetto.parse</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="cornetto-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >Pycorneto</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="cornetto-module.html">Package&nbsp;cornetto</a> ::
        Module&nbsp;parse
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="cornetto.parse-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module parse</h1><p class="nomargin-top"><span class="codelink"><a href="cornetto.parse-pysrc.html">source&nbsp;code</a></span></p>
<p>parse the xml files which define the Cornetto database</p>

<hr />
<div class="fields">      <p><strong>Version:</strong>
        0.6
      </p>
      <p><strong>Author:</strong>
        Erwin Marsi &lt;e.c.marsi@uvt.nl&gt;
      </p>
</div><!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="cornetto.parse-module.html#_parse_cdb_lu" class="summary-sig-name" onclick="show_private();">_parse_cdb_lu</a>(<span class="summary-sig-arg">file</span>,
        <span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Parse xml file which defines the lexical units.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_cdb_lu">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_parse_lex_units"></a><span class="summary-sig-name">_parse_lex_units</span>(<span class="summary-sig-arg">parser</span>,
        <span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_lex_units">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="cornetto.parse-module.html#_parse_cdb_syn" class="summary-sig-name" onclick="show_private();">_parse_cdb_syn</a>(<span class="summary-sig-arg">file</span>,
        <span class="summary-sig-arg">c_lu_id2lu</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Parse xml file which defines the synsets.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_cdb_syn">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_relations_to_edges"></a><span class="summary-sig-name">_relations_to_edges</span>(<span class="summary-sig-arg">c_lu_id2lu</span>,
        <span class="summary-sig-arg">sy_id2synset</span>,
        <span class="summary-sig-arg">sy_id2lus</span>,
        <span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Convert relations to graph edges</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_relations_to_edges">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="cornetto.parse-module.html#_synonym_relations_to_edges" class="summary-sig-name" onclick="show_private();">_synonym_relations_to_edges</a>(<span class="summary-sig-arg">synset_el</span>,
        <span class="summary-sig-arg">c_lu_id2lu</span>,
        <span class="summary-sig-arg">sy_id2lus</span>,
        <span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Add edges between all synonym lexical units in the graph.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_synonym_relations_to_edges">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="add_edge"></a><span class="summary-sig-name">add_edge</span>(<span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">from_node</span>,
        <span class="summary-sig-arg">to_node</span>,
        <span class="summary-sig-arg">relation</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#add_edge">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_wn_internal_relations_to_edges"></a><span class="summary-sig-name">_wn_internal_relations_to_edges</span>(<span class="summary-sig-arg">synset_el</span>,
        <span class="summary-sig-arg">c_lu_id2lu</span>,
        <span class="summary-sig-arg">sy_id2lus</span>,
        <span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Add edges between lexical units from this synset to other lexical 
      units from related synsets.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_wn_internal_relations_to_edges">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="cornetto.parse-module.html#parse_cdb" class="summary-sig-name">parse_cdb</a>(<span class="summary-sig-arg">cdb_lu</span>,
        <span class="summary-sig-arg">cdb_syn</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      parse the xml files which define the Cornetto database</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#parse_cdb">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_parse_count_totals"></a><span class="summary-sig-name">_parse_count_totals</span>(<span class="summary-sig-arg">parser</span>)</span><br />
      parse per category and overall counts from attributes of cdb_lu 
      document root</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_count_totals">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_parse_cdb_lu_with_counts"></a><span class="summary-sig-name">_parse_cdb_lu_with_counts</span>(<span class="summary-sig-arg">file</span>,
        <span class="summary-sig-arg">graph</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      an extension of _parse_cdb_lu which also parses the count totals</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_cdb_lu_with_counts">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_check_subcounts"></a><span class="summary-sig-name">_check_subcounts</span>(<span class="summary-sig-arg">parser</span>)</span><br />
      check that (at least one of the) lexical units have a 'subcounts' 
      attribute</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#_check_subcounts">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="parse_cdb_with_counts"></a><span class="summary-sig-name">parse_cdb_with_counts</span>(<span class="summary-sig-arg">cdb_lu</span>,
        <span class="summary-sig-arg">cdb_syn</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      an extension of parse_cdb which also parses the count totals</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="cornetto.parse-pysrc.html#parse_cdb_with_counts">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__revision__"></a><span class="summary-name">__revision__</span> = <code title="'$Id: parse.py 1148 2009-11-16 12:00:20Z emarsi $'"><code class="variable-quote">'</code><code class="variable-string">$Id: parse.py 1148 2009-11-16 12:00:20Z emarsi $</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'cornetto'"><code class="variable-quote">'</code><code class="variable-string">cornetto</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="_parse_cdb_lu"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_parse_cdb_lu</span>(<span class="sig-arg">file</span>,
        <span class="sig-arg">graph</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_cdb_lu">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Parse xml file which defines the lexical units. Add lexical units (as 
  Element) to the XiGraph graph. Return the mappings form--&gt;lexical 
  units and lexical-unit-id--&gt;lexical-unit</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="_parse_cdb_syn"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_parse_cdb_syn</span>(<span class="sig-arg">file</span>,
        <span class="sig-arg">c_lu_id2lu</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="cornetto.parse-pysrc.html#_parse_cdb_syn">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Parse xml file which defines the synsets. Return the mappings 
  synset-id--&gt;synset and synset-id--&gt;list-of-lexical-units</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="_synonym_relations_to_edges"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_synonym_relations_to_edges</span>(<span class="sig-arg">synset_el</span>,
        <span class="sig-arg">c_lu_id2lu</span>,
        <span class="sig-arg">sy_id2lus</span>,
        <span class="sig-arg">graph</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="cornetto.parse-pysrc.html#_synonym_relations_to_edges">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add edges between all synonym lexical units in the graph. Also add a 
  new 'c_sy_id' attribute to lexical unit elements which lists all synsets 
  this unit belongs to.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="parse_cdb"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">parse_cdb</span>(<span class="sig-arg">cdb_lu</span>,
        <span class="sig-arg">cdb_syn</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="cornetto.parse-pysrc.html#parse_cdb">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>parse the xml files which define the Cornetto database</p>
  <p>Returns a tuple with the following information:</p>
  <ol start="1">
    <li>
      form2lu: a dict mapping word forms (i.e. a value of the 
      &quot;form-spelling&quot; attribute on a &lt;form&gt; element) to  
      the corresponding lexical unit (i.e. an Element instance resulting 
      from parsing the &lt;cdb_lu&gt; xml string)
    </li>
    <li>
      c_lu_id2lu: a dict which maps cornette lexical unit identifiers (i.e.
      the value of the c_lu_id attribute on a &lt;cdb_lu&gt; element) to a 
      lexical unit (i.e. an Element instance resulting from parsing the 
      &lt;cdb_lu&gt; xml string)
    </li>
    <li>
      sy_id2synset: a dict which maps cornette/wordnet synset identifiers 
      (i.e. the value of the &quot;c_sy_id&quot; or &quot;d_synset_id&quot;
      attribute on a &lt;cdb_synset&gt; element) to a lexical unit (i.e. an
      Element instance resulting from parsing the &lt;cdb_synset&gt; xml 
      string)
    </li>
    <li>
      graph: an instance of a subclass of Graph from the networkx package, 
      where
      <ul>
        <li>
          nodes are Element instances corresponding &lt;cdb_lu&gt; xml 
          strings
        </li>
        <li>
          edges are Element instances corresponding to &lt;relation&gt; 
          elements or to the synonym relation which holds between members 
          of the same synset
        </li>
      </ul>
      <p>The graph will XDiGraph for Networkx versions &lt;= 0.37 and 
      MultiDiGraph for networkx versions &gt;= 0.99</p>
    </li>
  </ol>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>cdb_lu</code></strong> (file or filename) - xml definition of the lexical units</li>
        <li><strong class="pname"><code>cdb_syn</code></strong> (file or filename) - xml definition of the synsets</li>
        <li><strong class="pname"><code>verbose</code></strong> (bool) - verbose output during parsing</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>tuple(dict, dict, dict, Graph subclass)</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="cornetto-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >Pycorneto</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Feb 22 20:26:38 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
